package com.deer.wms.review.manage.web;

import com.deer.wms.intercept.annotation.User;
import com.deer.wms.intercept.common.data.CurrentUser;
import com.deer.wms.project.root.util.BeanUtils;
import com.deer.wms.project.root.util.DateUtils;
import com.deer.wms.review.manage.model.BillRecord;
import com.deer.wms.review.manage.model.BillRecordCriteria;
import com.deer.wms.review.manage.service.BillRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.deer.wms.project.root.core.result.Result;
import com.deer.wms.project.root.core.result.ResultGenerator;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
* Created by ll on 2020/03/05.
*/
@Api(description = "订单跟踪信息api接口")
@RestController
@RequestMapping("/bill/records")
public class BillRecordController {

    @Autowired
    private BillRecordService billRecordService;

    @PostMapping
    public Result add(@RequestBody BillRecord billRecord) {
        billRecordService.save(billRecord);
        return ResultGenerator.genSuccessResult();
    }



    @GetMapping("/delete")
    public Result delete(Integer id) {
        billRecordService.removeById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(@RequestBody BillRecord billRecord) {
        billRecordService.updateById(billRecord);
        return ResultGenerator.genSuccessResult();
    }

    @GetMapping("/detail")
    public Result detail(Integer id) {
        BillRecord billRecord = billRecordService.getById(id);
        return ResultGenerator.genSuccessResult(billRecord);
    }

    @GetMapping("/list")
    public Result list(BillRecordCriteria criteria) {
        PageHelper.startPage(criteria.getPageNum(), criteria.getPageSize());
        List<BillRecord> list = billRecordService.findList(criteria);
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

}
